package com.h3bpm.web.protalHanding;

import OThinker.Common.DotNetToJavaStringHelper;
import com.h3bpm.handler.JSONUtils;
import com.h3bpm.handler.UserHelper;
import com.h3bpm.web.common.H3Property;
import com.h3bpm.web.common.utils.SqlUtil;
import com.h3bpm.web.util.DateUtil;
import com.unboundid.ldap.matchingrules.CaseExactStringMatchingRule;

import data.DataRow;
import data.DataTable;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.authentication.jaas.AbstractJaasAuthenticationProvider;
import org.springframework.util.CollectionUtils;

import java.util.*;

public class ThreadHelper {

	private static final Logger logger = LoggerFactory.getLogger(ThreadHelper.class);

	// 获取流程
	public static void getInstance(String businessUrl, String bpmUrl) {

		String sql = "";
		System.out.println("=============================================================");
		logger.debug("获取数据库实例——————————————");
		try {
			sql = "SELECT * FROM E_INSTANCE WHERE STATE='0'";
			DataTable table = SqlUtil.doQuery(sql);
			List<DataRow> entityRows = table.getEntityRows();
			if (!entityRows.isEmpty() && entityRows.size() > 0) {
				// String accessToken = UserHelper.judgeToken(businessUrl);
				HashMap<String, Object> map = new HashMap<>();
				for (DataRow userData : entityRows) {
					Boolean flag = true;
					String bizObjectSchemaCode = userData.getString("bizObjectSchemaCode");
					String intanceId = userData.getString("instanceId");
					String objectId = userData.getString("objectId");
					// 判断推送流程是否到EC系统
					if (getProcessSystem(bizObjectSchemaCode, H3Property.SYSTEM_EC)) {

						String intanceName = userData.getString("instanceName");
						if (!DotNetToJavaStringHelper.isNullOrEmpty(intanceId)
								&& DotNetToJavaStringHelper.isNullOrEmpty(intanceName)) {
							String intanceNameSql = "select InstanceName from ot_instancecontext where ObjectID = '"
									+ intanceId + "'";
							DataTable intanceNameTable = SqlUtil.doQuery(intanceNameSql);
							List<DataRow> intanceNameEntityRows = intanceNameTable.getEntityRows();
							if (!CollectionUtils.isEmpty(intanceNameEntityRows)) {
								intanceName = intanceNameEntityRows.get(0).getString("InstanceName");
							}
						}
						String originatorName = userData.getString("originatorName");
						String originator = userData.getString("originator");
						originator = getCode(originator);
						String bizObjectId = userData.getString("bizObjectId");
						String createTime = userData.getString("createTime");
						String postUrl = businessUrl + "/prod-api/workflow/addWorkflow";
						if (bizObjectSchemaCode.equals("ConsultingOutcomeDocument")
								|| bizObjectSchemaCode.equals("ProjectInformationSeal")
								|| bizObjectSchemaCode.equals("projectManageResultsReview")
								|| bizObjectSchemaCode.equals("tenderAgentFileSeal")
								|| bizObjectSchemaCode.equals("environmentalResultReview")
								|| bizObjectSchemaCode.equals("biddingDocument")
								|| bizObjectSchemaCode.equals("supervisionPlanningReport")
								|| bizObjectSchemaCode.equals("costConsultingReportSeal")
								|| bizObjectSchemaCode.equals("biddingInfoApplication")
								|| bizObjectSchemaCode.equals("businessRemoval")) {
							// 1 成果校审
							map.put("type", "1");
						}
						if (bizObjectSchemaCode.equals("projectWrittenFiling")) {
							// 1 书面归档
							map.put("type", "2");
						}
						// 获取业务类别
						System.out.println("—————————————获取业务类别开始—————————————");
						System.out.println("—————————————获取评审专家信息结束—————————————bizObjectSchemaCode="+bizObjectSchemaCode);
						System.out.println("—————————————获取评审专家信息结束—————————————bizObjectId="+bizObjectId);
						HashMap<String, Object> maps = getCategory(bizObjectSchemaCode, bizObjectId);
						if (!maps.isEmpty() && maps.size() > 0) {
							map.put("businessCategoryId", maps.get("businessCategoryId"));
							map.put("businessCategory", maps.get("businessCategory"));
							map.put("deptName", maps.get("deptName"));
							map.put("deptId", maps.get("deptId"));
							map.put("projectName", maps.get("projectName"));
							map.put("projectId", maps.get("projectId"));
							map.put("projectLeaderId", maps.get("projectLeaderId"));
							map.put("projectLeader", maps.get("projectLeader"));
							map.put("businessId", maps.get("businessId"));
						}
						// 获取评审专家信息
						
						logger.debug("—————————————获取评审专家信息开始—————————————");
						logger.debug("—————————————获取评审专家信息结束—————————————bizObjectSchemaCode="+bizObjectSchemaCode);
						logger.debug("—————————————获取评审专家信息结束—————————————bizObjectId="+bizObjectId);
						HashMap<String, Object> businessMaps = getBusinessInfo(bizObjectSchemaCode, bizObjectId);
						logger.debug("—————————————获取评审专家信息结束—————————————");
						if (!businessMaps.isEmpty() && businessMaps.size() > 0) {
							map.put("expert", maps.get("expert"));
							map.put("expertName", maps.get("expertName"));
						}

						map.put("originTime", createTime);
						map.put("intanceId", intanceId);
						map.put("intanceName", intanceName);
						map.put("originatorName", originatorName);
						map.put("originator", originator);
						map.put("bizObjectId", bizObjectId);
						map.put("bizObjectSchemaCode", bizObjectSchemaCode);
						map.put("instanceUrl", bpmUrl + UserHelper.pcInsUrl(intanceId));
						map.put("instanceH5url", bpmUrl + UserHelper.h5InsUrl(intanceId));
						map.put("instanceState", "0");
						// 获取该流程的审批节点
						String json = JSONUtils.toJson(map);
						System.out.println("EC请求链接=========="+postUrl);
						Map<String, Object> result = ThreadPost.postRequestResult(postUrl, json, null);
						System.out.println("EC返回值=========="+result);
						if (result == null || result.size() == 0) {
							logger.debug("返回值为空—————————————");
						} else {
							int res = (Integer) result.get("code");
							if (res == 200) {
								// 更新该数据状态 E_UPDATEINSTANCE state
								OrcaleHelper.updateInstance(intanceId, objectId);
								logger.debug("更新实例结果====================success");
							} else {
								logger.debug("更新实例结果====================失败");
							}
						}
					} else if (getProcessSystem(bizObjectSchemaCode, H3Property.SYSTEM_PORTAL)) {
						OrcaleHelper.updateInstance(intanceId, objectId);
					}
				}
			} else {
				logger.debug("获取数据库实例——————————————无流程实例");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/**
	 *
	 * @describe 获取该流程的审批节点
	 * @params [intanceId] 流程id
	 * @return java.util.HashMap<java.lang.String,java.lang.Object>
	 * @author VillWang
	 * @date 2020/5/31
	 * @other
	 *
	 */
	private static HashMap<String, Object> getApproval(String intanceId) {

		if (intanceId != null && !"".equals(intanceId)) {
			try {
				HashMap<String, Object> map = new HashMap<>();
				String sql = "select ParticipantName,DisplayName,ObjectId" + "from OT_workItem where InstanceId='"
						+ intanceId + "' order by ReceiveTime desc";
				DataTable table = SqlUtil.doQuery(sql);
				List<DataRow> entityRows = table.getEntityRows();
				if (!entityRows.isEmpty() && entityRows.size() > 0) {
					String ParticipantName = entityRows.get(0).getString("ParticipantName");
					String DisplayName = entityRows.get(0).getString("DisplayName");
					String taskObjectId = entityRows.get(0).getString("ObjectId");
					map.put("ParticipantName", ParticipantName);
					map.put("DisplayName", DisplayName);
					map.put("taskObjectId", taskObjectId);
					return map;
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			logger.debug("获取业务类别——————————————数据为空");
		}
		return null;
	}

	private static String getCode(String objectId) {

		if (objectId != null && !"".equals(objectId)) {
			try {
				String sql = "select code from OT_User where objectId='" + objectId + "'";
				DataTable table = SqlUtil.doQuery(sql);
				List<DataRow> entityRows = table.getEntityRows();
				if (!entityRows.isEmpty() && entityRows.size() > 0) {
					String code = entityRows.get(0).getString("code");
					return code;
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			logger.debug("获取业务类别——————————————数据为空");
		}
		return null;
	}

	// 处理更新实例
	public static void updateInstance(String businessUrl, String bpmUrl) {

		String sql = "";
		logger.debug("获取数据库更新实例——————————————");
		sql = "SELECT * FROM E_UPDATEINSTANCE WHERE STATE='0'";
		try {
			DataTable table = SqlUtil.doQuery(sql);
			List<DataRow> entityRows = table.getEntityRows();
			if (!entityRows.isEmpty() && entityRows.size() > 0) {
				// String accessToken = UserHelper.judgeToken(businessUrl);
				HashMap<String, Object> map = new HashMap<>();
				for (DataRow userData : entityRows) {
					String instanceId = userData.getString("instanceId");
					String objectId = userData.getString("objectId");
					String instanceState = userData.getString("instanceState");
					map.put("intanceId", instanceId);
					if (instanceState.equals("4")) {
						instanceState = "1";
					}
					if (instanceState.equals("5")) {
						instanceState = "2";
					}
					String bizObjectSchemaCode = getBizObjectSchemaCode(instanceId);
					// 判断推送流程是否到EC系统
					if (getProcessSystem(bizObjectSchemaCode, H3Property.SYSTEM_EC)) {
						map.put("instanceState", instanceState);
						map.put("bizObjectSchemaCode", bizObjectSchemaCode);
						map.put("end_time", DateUtil.getCurrDateTime2());
						
						
						String sqlBizObjectId = "SELECT BizObjectId FROM ot_instancecontext WHERE ObjectID='"+instanceId+"'";
						DataTable table1 = SqlUtil.doQuery(sqlBizObjectId);
						List<DataRow> entityRows1 = table1.getEntityRows();
						if (!entityRows1.isEmpty() && entityRows1.size() > 0) {
							String bizObjectId = entityRows1.get(0).getString("BizObjectId");
							
							logger.debug("—————————————获取评审专家信息开始—————————————");
							logger.debug("—————————————获取评审专家信息结束—————————————bizObjectSchemaCode="+bizObjectSchemaCode);
							logger.debug("—————————————获取评审专家信息结束—————————————bizObjectId="+bizObjectId);
							
							HashMap<String, Object> businessMaps = getBusinessInfo(bizObjectSchemaCode, bizObjectId);
							logger.debug("—————————————获取评审专家信息结束—————————————");
							if (!businessMaps.isEmpty() && businessMaps.size() > 0) {
								map.put("expert", businessMaps.get("expert"));
								map.put("expertName", businessMaps.get("expertName"));
							}
						}
						
						
						// map.put("objectId",objectId);
						String url = businessUrl + "/prod-api/workflow/updateWorkflow";
						String json = JSONUtils.toJson(map);
						Map<String, Object> result = ThreadPost.postRequestResult(url, json, null);
						if (result == null || result.size() == 0) {
							logger.debug("返回值为空—————————————");
						} else {
							int res = (Integer) result.get("code");
							if (res == 200) {
								// 更新该数据状态 E_UPDATEINSTANCE state
								OrcaleHelper.updateInstanceUpdate(objectId);
								logger.debug("更新实例结果====================success");
							} else {
								logger.debug("更新实例结果====================失败");
							}
						}
					} else if (getProcessSystem(bizObjectSchemaCode, H3Property.SYSTEM_PORTAL)) {
						OrcaleHelper.updateInstanceUpdate(objectId);
					}
				}
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static String getBizObjectSchemaCode(String instanceId) {

		if (instanceId != null && !"".equals(instanceId)) {
			try {
				String sql = "SELECT bizObjectSchemaCode FROM E_INSTANCE WHERE instanceId='" + instanceId + "'";
				DataTable table = SqlUtil.doQuery(sql);
				List<DataRow> entityRows = table.getEntityRows();
				if (!entityRows.isEmpty() && entityRows.size() > 0) {
					String bizObjectSchemaCode = entityRows.get(0).getString("bizObjectSchemaCode");
					logger.debug("获取流程编码—————————bizObjectSchemaCode—————" + bizObjectSchemaCode);
					return bizObjectSchemaCode;
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			logger.debug("获取流程编码——————————————数据为空");
		}
		return null;
	}

	/**
	 *
	 * @describe 获取业务类别
	 * @params [bizObjectSchemaCode, bizObjectId] bizObjectSchemaCode主表编码
	 *         bizObjectId 主表objectid
	 * @return java.lang.String
	 * @author VillWang
	 * @date 2020/5/29
	 * @other
	 *
	 */
	private static HashMap<String, Object> getCategory(String bizObjectSchemaCode, String bizObjectId) {
		HashMap<String, Object> map = new HashMap<>();
		if (bizObjectSchemaCode != null && !"".equals(bizObjectSchemaCode) && bizObjectId != null
				&& !"".equals(bizObjectId)) {
			try {

				String sql = "select businessCategoryId,businessCategory,deptName,deptId,projectName,projectId,projectLeaderId,projectLeader,businessId"
						+ " from i_" + bizObjectSchemaCode + " where objectId='" + bizObjectId + "'";
				DataTable table = SqlUtil.doQuery(sql);
				List<DataRow> entityRows = table.getEntityRows();
				if (!entityRows.isEmpty() && entityRows.size() > 0) {
					String businessCategoryId = entityRows.get(0).getString("businessCategoryId");
					String deptId = entityRows.get(0).getString("deptId");
					String businessCategory = entityRows.get(0).getString("businessCategory");
					String deptName = entityRows.get(0).getString("deptName");
					String projectName = entityRows.get(0).getString("projectName");
					String projectId = entityRows.get(0).getString("projectId");
					String projectLeaderId = entityRows.get(0).getString("projectLeaderId");
					String projectLeader = entityRows.get(0).getString("projectLeader");
					String businessId = entityRows.get(0).getString("businessId");
					map.put("businessId", businessId);
					map.put("projectLeaderId", projectLeaderId);
					map.put("projectLeader", projectLeader);
					map.put("businessCategoryId", businessCategoryId);
					map.put("businessCategory", businessCategory);
					map.put("deptName", deptName);
					map.put("deptId", deptId);
					map.put("projectName", projectName);
					map.put("projectId", projectId);
					return map;
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			logger.debug("获取业务类别——————————————数据为空");
		}
		return map;
	}

	// 处理代办
	public static void getTask(String businessUrl, String bpmUrl) {
		String sql = "";
		logger.debug("获取数据库代办——————————————");
		try {
			sql = "SELECT * FROM E_TASK WHERE STATE='0'";
			String workItemSql = "SELECT u.code as ParticipantId,Participant,DisplayName from ot_workitem w"
					+ " left join ot_user u on u.ObjectID = w.Participant" + " where InstanceId = '%s'";
			DataTable table = SqlUtil.doQuery(sql);
			List<DataRow> entityRows = table.getEntityRows();
			if (!entityRows.isEmpty() && entityRows.size() > 0) {
				// String accessToken = UserHelper.judgeToken(businessUrl);
				for (DataRow userData : entityRows) {
					ArrayList<HashMap<String, Object>> tasks = new ArrayList<>();
					HashMap<String, Object> body = new HashMap<>();
					HashSet<String> participantIds = new HashSet<>();
					HashSet<String> participants = new HashSet<>();
					HashSet<String> displayNames = new HashSet<>();
					// 任务id
					String taskId = userData.getString("taskId");
					// 任务id
					String objectId = userData.getString("OBJECTID");
					// 流程id
					String instance = userData.getString("INSTANCE");
					String bizObjectSchemaCode = getBizObjectSchemaCode(instance);
					// 判断推送流程是否到EC系统
					if (getProcessSystem(bizObjectSchemaCode, H3Property.SYSTEM_EC)) {
						if (StringUtils.isNotBlank(instance)) {
							DataTable tables = SqlUtil.doQuery(String.format(workItemSql, instance));
							List<DataRow> workItemRows = tables.getEntityRows();
							if (!workItemRows.isEmpty() && workItemRows.size() > 0) {
								for (DataRow workItem : workItemRows) {
									String ParticipantId = workItem.getString("ParticipantId");
									String Participant = workItem.getString("Participant");
									String DisplayName = workItem.getString("DisplayName");
									participantIds.add(ParticipantId);
									participants.add(Participant);
									displayNames.add(DisplayName);
								}
							}
						}
						
						String sqlBizObjectId = "SELECT BizObjectId FROM ot_instancecontext WHERE ObjectID='"+userData.getString("INSTANCE")+"'";
						DataTable table1 = SqlUtil.doQuery(sqlBizObjectId);
						List<DataRow> entityRows1 = table1.getEntityRows();
						if (!entityRows1.isEmpty() && entityRows1.size() > 0) {
							String bizObjectId = entityRows1.get(0).getString("BizObjectId");
							
							logger.debug("—————————————获取评审专家信息开始—————————————");
							logger.debug("—————————————获取评审专家信息结束—————————————bizObjectSchemaCode="+bizObjectSchemaCode);
							logger.debug("—————————————获取评审专家信息结束—————————————bizObjectId="+bizObjectId);
							
							HashMap<String, Object> businessMaps = getBusinessInfo(bizObjectSchemaCode, bizObjectId);
							logger.debug("—————————————获取评审专家信息结束—————————————");
							if (!businessMaps.isEmpty() && businessMaps.size() > 0) {
								body.put("expert", businessMaps.get("expert"));
								body.put("expertName", businessMaps.get("expertName"));
							}
						}
						
						// 创建实例返回值
//                    String displayName=userData.getString("displayName");
//                    String participant=userData.getString("participant");
						body.put("displayName", StringUtils.join(displayNames, ","));
						body.put("participant", StringUtils.join(participants, ","));
						body.put("url", bpmUrl + userData.getString("URL"));
						body.put("h5Url", bpmUrl + userData.getString("H5URL"));
						body.put("intanceId", userData.getString("INSTANCE"));
						body.put("participantId", StringUtils.join(participantIds, ","));
						String url = businessUrl + "/prod-api/workflow/updateWorkflow";
						String json = JSONUtils.toJson(body);
						Map<String, Object> result = ThreadPost.postRequestResult(url, json, null);
						if (result == null || result.size() == 0) {
							logger.debug("返回值为空—————————————");
						} else {
							// 处理返回值
							int res = (Integer) result.get("code");
							if (res == 200) {
								// 更新该数据状态 E_UPDATEINSTANCE state
								OrcaleHelper.updateTask(objectId);
								logger.debug("更新实例结果====================success");
							} else {
								logger.debug("更新实例结果====================失败");
							}

						}
					} else if (getProcessSystem(bizObjectSchemaCode, H3Property.SYSTEM_PORTAL)) {
						OrcaleHelper.updateInstanceUpdate(objectId);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/**
	 * 获取流程所属系统
	 * 
	 * @param bizObjectSchemaCode
	 * @return
	 */
	public static boolean getProcessSystem(String bizObjectSchemaCode, String pushSystem) {
		boolean flag = false;
		try {
			String systemSql = "select System from i_processsystem where IsDisable='否' and ProcessCode='%s'";
			DataTable systemTable = SqlUtil.doQuery(String.format(systemSql, bizObjectSchemaCode));
			List<DataRow> systemEntityRows = systemTable.getEntityRows();
			if (!CollectionUtils.isEmpty(systemEntityRows)) {
				String system = systemEntityRows.get(0).getString("System");
				flag = StringUtils.contains(system, pushSystem);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
//        logger.info("流程编码：{}，推送系统{}，流程是否属推送系统{}",bizObjectSchemaCode, pushSystem, flag);
		return flag;
	}

	/**
	 *
	 * @describe 获取表单业务信息
	 * @params [bizObjectSchemaCode, bizObjectId] bizObjectSchemaCode主表编码
	 *         bizObjectId 主表objectid
	 * @return java.lang.String
	 * @author pyf
	 * @date 2021/5/21
	 * @other
	 *
	 */
	private static HashMap<String, Object> getBusinessInfo(String bizObjectSchemaCode, String bizObjectId) {
		HashMap<String, Object> map = new HashMap<>();
		if (bizObjectSchemaCode != null && !"".equals(bizObjectSchemaCode) && bizObjectId != null
				&& !"".equals(bizObjectId)) {
			try {
				String expertId = "";
				if ("ConsultingOutcomeDocument".equals(bizObjectSchemaCode)) {// 项目咨询报告盖章流程
					String sql = "select experts1,experts2,experts3,experts4,experts8"
							+ " from i_" + bizObjectSchemaCode + " where objectId='" + bizObjectId + "'";
					logger.debug("—————————————获取评审专家信息结束—————————————sql="+sql);
					DataTable table = SqlUtil.doQuery(sql);
					List<DataRow> entityRows = table.getEntityRows();
					if (!entityRows.isEmpty() && entityRows.size() > 0) {
						logger.debug("—————————————获取评审专家信息结束—————————————entityRows="+entityRows);
						String experts1 = entityRows.get(0).getString("experts1");
						String experts2 = entityRows.get(0).getString("experts2");
						String experts3 = entityRows.get(0).getString("experts3");
						String experts4 = entityRows.get(0).getString("experts4");
						String experts8 = entityRows.get(0).getString("experts8");
						if(experts1 != null && !"".equals(experts1)) {
							expertId = experts1;
						}
						if(experts2 != null && !"".equals(experts2)) {
							expertId = experts2;
						}
						if(experts3 != null && !"".equals(experts3)) {
							expertId = experts3;
						}
						if(experts4 != null && !"".equals(experts4)) {
							expertId = experts4;
						}
						if(experts8 != null && !"".equals(experts8)) {
							expertId = experts8;
						}
					}
				} else if ("biddingDocument".equals(bizObjectSchemaCode)) {// 招标文件盖章申请
					String sql = "select experts"
							+ " from i_" + bizObjectSchemaCode + " where objectId='" + bizObjectId + "'";
					DataTable table = SqlUtil.doQuery(sql);
					List<DataRow> entityRows = table.getEntityRows();
					if (!entityRows.isEmpty() && entityRows.size() > 0) {
						String experts = entityRows.get(0).getString("experts");
						if(experts != null && !"".equals(experts)) {
							expertId = experts;
						}
					}
				} else if ("costConsultingReportSeal".equals(bizObjectSchemaCode)) {// 造价咨询报告盖章申请
					String sql = "select experts"
							+ " from i_" + bizObjectSchemaCode + " where objectId='" + bizObjectId + "'";
					DataTable table = SqlUtil.doQuery(sql);
					List<DataRow> entityRows = table.getEntityRows();
					if (!entityRows.isEmpty() && entityRows.size() > 0) {
						String experts = entityRows.get(0).getString("experts");
						if(experts != null && !"".equals(experts)) {
							expertId = experts;
						}
					}
				} else if ("projectManageResultsReview".equals(bizObjectSchemaCode)) {// 项目管理成果文件报审
					String sql = "select experts,experts2"
							+ " from i_" + bizObjectSchemaCode + " where objectId='" + bizObjectId + "'";
					DataTable table = SqlUtil.doQuery(sql);
					List<DataRow> entityRows = table.getEntityRows();
					if (!entityRows.isEmpty() && entityRows.size() > 0) {
						String experts = entityRows.get(0).getString("experts");
						String experts2 = entityRows.get(0).getString("experts2");
						if(experts != null && !"".equals(experts)) {
							expertId = experts;
						}
						if(experts2 != null && !"".equals(experts2)) {
							expertId = experts2;
						}
					}
				} else if ("supervisionPlanningReport".equals(bizObjectSchemaCode)) {// 监理规划报审
					
					String sql = "select oos.UserID as experts from ot_orgpost oo LEFT JOIN ot_orgstaff oos on oo.ObjectID=oos.ParentObjectID where oo.code='chiefEngineer'";
					DataTable table = SqlUtil.doQuery(sql);
					List<DataRow> entityRows = table.getEntityRows();
					if (!entityRows.isEmpty() && entityRows.size() > 0) {
						String experts = entityRows.get(0).getString("experts");
						if(experts != null && !"".equals(experts)) {
							expertId = experts;
						}
					}
				}
				
				if(!"".equals(expertId)) {
					String getUserSql = "select name,code from ot_user where objectId='" + expertId + "'";
					DataTable userTable = SqlUtil.doQuery(getUserSql);
					List<DataRow> userRows = userTable.getEntityRows();
					if(userRows!=null && userRows.size()>0) {
						map.put("expert", userRows.get(0).getString("code"));
						map.put("expertName", userRows.get(0).getString("name"));
					}
				}
				return map;
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			logger.debug("获取表单业务信息——————————————数据为空");
		}
		return map;
	}
}
